//获取当前时间，不同浏览器显示不一致，所以最好改成字符串的形式
function getDateStr() {
    let dd = new Date();
    let y = dd.getFullYear();
    let m = (dd.getMonth()+1)<10?`0`+(dd.getMonth()+1):(dd.getMonth()+1);//获取当前月份的日期
    let d = (dd.getDate())<10?`0`+dd.getDate():dd.getDate();
    return y+m+d;
}

//日期 --> 字符串
function DateToStr(date) {
    let year = date.getFullYear();//年
    let month = date.getMonth();//月
    let day = date.getDate();//日
    let hours = date.getHours();//时
    let min = date.getMinutes();//分
    let second = date.getSeconds();//秒
    return year + "-" +
        ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" +
        (day > 9 ? day : ("0" + day)) + " " +
        (hours > 9 ? hours : ("0" + hours)) + ":" +
        (min > 9 ? min : ("0" + min)) + ":" +
        (second > 9 ? second : ("0" + second));
}

//字符串 --> 日期
function StrToDate(datestr) {
    return new Date(datestr);
}